/**
 * @Project: Runer
 * @Title: ToastUtil.java
 * @Package com.runlooker.runer.util
 * @author town
 * @date 2014-5-8 下午9:45:22
 * @Copyright: 2014 www.yineng.com.cn Inc. All rights reserved.
 * @version V1.0
 */
package com.runlooker.runer.util;

import android.content.Context;
import android.os.Handler;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.runlooker.runer.R;

/**
 * 
 * 
 * 避免重复出现的土司工具
 * 
 * @ClassName ToastUtil
 * @Description 模块描述
 * @author town
 * @Date 2014-5-8
 */
public class T {

	private static Toast mToast;

	public static Toast getInstanceToast(Context context) {
		if (mToast == null) {
			mToast = Toast.makeText(context, "warning", Toast.LENGTH_SHORT);
		} else {
			mToast.cancel();
			mToast = Toast.makeText(context, "warning", Toast.LENGTH_SHORT);
		}
		return mToast;
	}

	/**
	 * 
	 * 
	 * @Title: showToast
	 * @Description: 方法描述
	 * @param context
	 * @param text
	 */
	public static void showShort(Context context, String text) {
		try {
			Toast toast = getInstanceToast(context);
			toast.setText(text);
			toast.setDuration(Toast.LENGTH_SHORT);
			toast.setGravity(Gravity.CENTER, 0, 0);
			toast.show();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void showLong(Context context, String text) {
		try {
			Toast toast = getInstanceToast(context);
			toast.setText(text);
			toast.setDuration(Toast.LENGTH_LONG);
			toast.setGravity(Gravity.CENTER, 0, 0);
			toast.show();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
